|
Filling a table manually As you already know, there are two versions of the cross-table: the "DB crosstable" and the "Cross-table." All this time we’ve been working with the first object attached to the data from the DB table and fills itself automatically, as soon as the report runs. Let us examine the second object, "Cross-table." This object is not attached to the data from DB. Therefore, you are to fill the table with data manually. This object possesses a similar editor, but you would have to select the number of dimensions in the table’s titles and in its cells instead of DB fields:
Let us demonstrate operating with the "Cross-table" object with an example. Put an object on the list of the report and set it in a way, as it is shown in the previous picture: the number of levels in the strings’ title is "1," in the columns’ title – "2," in the cell – "1." To fill the table with data, let us use the "OnBeforePrint" object’s event handler: procedure In the handler, it is necessary to add the required data into the table via the "TfrxCrossView.AddValue" method. This method has three parameters; each of them is an array of values of the "Variant" type. The first parameter is the row's value, the second one is the column’s value, and the third one contains the cells’ values. Note that the number of values in each array should correspond to the object’s setting! In our case, the object has one level in the rows' title, two levels in the columns’ title, and one level of cells. Therefore, we transfer one value for rows, two values for columns, and one value for cells into the AddValue. When running the report, we would see the following:
One can use the "AddValue" method for the "DB cross-table" object as well. This allows adding the data (which are not in the data source attached to the object) into the cross-table. Otherwise, if there are such data, they are summarized with the data in the table. |